/*
 * =====================================================================================
 *
 *       Filename:  genFeatures.cpp
 *
 *    Description:  Generate features of given character
 *
 *        Version:  1.0
 *        Created:  10/07/12 14:28:17
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Moos Hueting (mh), mooshueting@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include <iostream>
#include <cv.h>
#include <highgui.h>
#include <time.h>
#include "features/char_features.h"
#include "thin.h"

using namespace std;
using namespace cv;

int main(int argc, char* argv[]) {
    Mat image = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
    threshold(image, image, 100, 255, THRESH_BINARY);
//    image = thin(image);
    //resize(image, image, Size(0,0), 10, 10, INTER_NEAREST);


    // generate features
    int rCorners = corners(image);
    float rHeight = height(image);
    float rWidth = width(image);
    float rConvexity = convexity(image);
    float rComplexity = complexity(image);
    int rDiffSegs0 = diffsegs(image, 0);
    int rDiffSegs1 = diffsegs(image, 1);
//    int rAvgThickness0 = avgThickness(image, 0);
//    int rAvgThickness1 = avgThickness(image, 1);
    int rEndpoints = endpoints(image);
    float rRatio = ratio(image);
    int rHoles = holes(image);
    int rDC = diagConnections(image);
    int rCC = connectedComponents(image);
//    float rAxisMean0 = axismean(image, 0);
//    float rAxisMean1 = axismean(image, 1);
    float rDensity = density(image);
//    int rJunctions = junctions(image);
    float rVariance0 = variance(image, 0);
    float rVariance1 = variance(image, 1);
//    int rHoleNoise = holenoise(image);
    float rGradOrient0 = gradOrientation(image, 0);
    float rGradOrient1 = gradOrientation(image, 1);
    float rGradOrient2 = gradOrientation(image, 2);
    float rGradOrient3 = gradOrientation(image, 3);
    float rGradOrient4 = gradOrientation(image, 4);
    float rGradOrient5 = gradOrientation(image, 5);
    float rGradOrient6 = gradOrientation(image, 6);
    float rGradOrient7 = gradOrientation(image, 7);
    float rCurvature = curvature(image);
/*     float rGradOrient8 = gradOrientation(image, 8);
 *     float rGradOrient9 = gradOrientation(image, 9);
 *     float rGradOrient10 = gradOrientation(image, 10);
 *     float rGradOrient11 = gradOrientation(image, 11);
 *     float rGradOrient12 = gradOrientation(image, 12);
 *     float rGradOrient13 = gradOrientation(image, 13);
 *     float rGradOrient14 = gradOrientation(image, 14);
 *     float rGradOrient15 = gradOrientation(image, 15);
 */


    // output featuimage
    cout << rCorners << ", " << rHeight << ", " << rWidth << ", "<< rConvexity << ", " << rComplexity << ", " << rDiffSegs0 << ", " << rDiffSegs1 << ", " << rEndpoints << ", " << rRatio << ", " << rHoles << ", " << rDC << ", " << rCC << ", " << rDensity << ", " << rVariance0 << ", " << rVariance1 << ", " << rGradOrient0 << ", " << rGradOrient1 << ", " << rGradOrient2 << ", " << rGradOrient3 << ", " << rGradOrient4 << ", " << rGradOrient5 << ", " << rGradOrient6 << ", " << rGradOrient7 << ", " << rCurvature << endl;
    
/*     << ", " << rGradOrient8 << ", " << rGradOrient9 << ", " << rGradOrient10 << ", " << rGradOrient11 << ", " << rGradOrient12 << ", " << rGradOrient13 << ", " << rGradOrient14 << ", " << rGradOrient15 << ", " << rHoleNoise << endl;
 */

}
